package com.interview.ujiuye9;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Copyright (C), 2018-2020
 * FileName: MapIterator
 * Author:   kongfanyu
 * Date:     2020/11/19 20:14
 */
public class MapIterator {
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        map.put("a","100");
        map.put("b","200");
        map.put("c","300");
        map.put("d","400");

        Set<String> keySet = map.keySet();
        for (String s : keySet) {
            String value = map.get(s);
            System.out.println(s + "===" + value);
        }
        System.out.println(keySet);
        Iterator<String> iterator = keySet.iterator();
        while (iterator.hasNext()){
            String key = iterator.next();
            String value = map.get(key);
            System.out.println(key + "~~~~" + value);
        }

        /*Set<Map.Entry<String, String>> entrySet = map.entrySet();
        Iterator<Map.Entry<String, String>> iterator = entrySet.iterator();
        while (iterator.hasNext()){
            Map.Entry<String, String> entry = iterator.next();
            System.out.println(entry.getKey()+"~~"+entry.getValue());
        }*/
    }
}
